<?php

require_once(PATH_CLASS.'widget.class.php');
require_once(PATH_CLASS.'match.class.php');

class score extends widget{
  
  const CLASS_NAME = 'score';

  public function getDefaults() {
    $ret = parent::getDefaults();
    $ret = array_merge(array(
       'id'         => null
      ,'pars'       => array()
    ),$ret);
    
    return $ret;
  }

  public function __construct($params) {
    parent::__construct($params);
  }
  
  protected function _get_called_class() { return self::CLASS_NAME;  }

  public function _render() {
    $pars = $this->params;
    
    $pars = array_merge(array('saison_id'=>0,'type'=>''),$pars);    
    
    $score = match::getRanking($pars['saison_id'], $pars['type']);
    
    $params = array(
         'score'    =>  $score
    );
    
    $params = array_merge($params,$pars);

    $layout = $this->renderTplFromFile(__FILE__, $params);
    
    return $layout;
  }
}

